<!DOCTYPE html>
<html lang="en">
	<?php $this->load->view('vheader');?>
	<body>
		<?php $this->load->view('vnavbar'); ?>
		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<div class="main-container-inner">
				<a class="menu-toggler" id="menu-toggler" href="#">
					<span class="menu-text"></span>
				</a>

				<?php $this->load->view('vsidebar'); ?>
				<div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>

						<ul class="breadcrumb">
							<li>
								<i class="icon-home home-icon"></i>
								<a href="#">Daftar User</a>
							</li>
							<!--
							<li class="active">Dashboard</li>
							-->
						</ul><!-- .breadcrumb -->

						<div class="nav-search" id="nav-search">
							<!--
							<form class="form-search">
								<span class="input-icon">
									<input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
									<i class="icon-search nav-search-icon"></i>
								</span>
							</form>
							-->
						</div><!-- #nav-search -->
					</div>

					<div class="page-content">
						
						<div class="page-header">
							<h1>
								Daftar User
								<!--
								<small>
									<i class="icon-double-angle-right"></i>
									overview &amp; stats
								</small>
								-->
							</h1>
						</div><!-- /.page-header -->
						
						<div class="row">
							<div class="col-xs-12">
								<div class="table-header">
									Hasil Pencarian Data User
						            <div  align='right'>    
        						        <a align='right' href=<?= base_url() ?>index.php/user/tambahuser class="btn btn-xs btn-primary green"  data-toggle="modal" >
        				        			<i class="icon-plus bigger-110">
        				            			Tambah User
        				        			</i>
        				    			</a>
	    							</div>
								</div>
        				
								<div class="table-responsive">
									<table id="sample-table-2" class="table table-striped table-bordered table-hover" align="center">
										<thead>
											<tr style="text-align:center">
												<th width="8"  style="text-align:center">No</th>
												<th width="20" style="text-align:center">Ganti Password / Delete</th>
												<th width="25"  style="text-align:center">Nama User</th>
												<th width="25"  style="text-align:center">Role</th>
												<th width="25"  style="text-align:center">Cabang</th>
												<th width="25"  style="text-align:center">Customer</th>
												<th width="25"  style="text-align:center">Last Login</th>
											</tr>
										</thead>
   	    				
										<tbody>
											<?php $i = 1; foreach ($queryuser->result() as $row) { ?>
												<tr> 
													<td width="3"><?= $i++; ?></td>
													<td align="center">
														<div>
															<a href="#" id="<?= $row->username;?>" class="orange resetpassword" title="Ganti Password" rel="tooltip">
																<i class="icon-key bigger-130"></i>
															</a>  &nbsp
															<a href="#" id="<?php echo $row->username;?>" class="red hapususer" title="hapus" rel="tooltip">
																<i class="icon-trash bigger-130"></i>
															</a>
														</div>
													</td>
													<td style="width:200px"><?= $row->username ?></td>
													<td style="width:200px"><?= $row->detil ?></td>
													<td style="width:200px"><?= $row->nama_kota ?></td>
													<td style="width:200px"><?= $row->nama_customer ?></td>
													<td style="width:200px"><?= $row->last_login ?></td>
												</tr>
											<?php } ?>
										</tbody>
									</table>
								</div>
							</div>
						</div>


					<!-- /.page-content -->
				</div><!-- /.main-content -->

				<!--
				<div class="ace-settings-container" id="ace-settings-container">
					<div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
						<i class="icon-cog bigger-150"></i>
					</div>
					<div class="ace-settings-box" id="ace-settings-box">
						<div>
							<div class="pull-left">
								<select id="skin-colorpicker" class="hide">
									<option data-skin="default" value="#438EB9">#438EB9</option>
									<option data-skin="skin-1" value="#222A2D">#222A2D</option>
									<option data-skin="skin-2" value="#C6487E">#C6487E</option>
									<option data-skin="skin-3" value="#D0D0D0">#D0D0D0</option>
								</select>
							</div>
							<span>&nbsp; Choose Skin</span>
						</div>

						<div>
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-navbar" />
							<label class="lbl" for="ace-settings-navbar"> Fixed Navbar</label>
						</div>

						<div>
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-sidebar" />
							<label class="lbl" for="ace-settings-sidebar"> Fixed Sidebar</label>
						</div>

						<div>
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-breadcrumbs" />
							<label class="lbl" for="ace-settings-breadcrumbs"> Fixed Breadcrumbs</label>
						</div>

						<div>
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-rtl" />
							<label class="lbl" for="ace-settings-rtl"> Right To Left (rtl)</label>
						</div>

						<div>
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-add-container" />
							<label class="lbl" for="ace-settings-add-container">
								Inside
								<b>.container</b>
							</label>
						</div>
					</div>
				</div>--><!-- /#ace-settings-container -->
			<!--</div>--><!-- /.main-container-inner -->

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="icon-double-angle-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->

		<!-- basic scripts -->

		<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='<?= base_url() ?>assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='<?= base_url() ?>assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->

		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='<?= base_url() ?>assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>

		<!-- page specific plugin scripts -->

		<script src="<?= base_url() ?>assets/js/jquery.dataTables.min.js"></script>
		<script src="<?= base_url() ?>assets/js/jquery.dataTables.bootstrap.js"></script>

		<!-- inline scripts related to this page -->

       	<script type="text/javascript">
        	$(function() {
                $(".resetpassword").click(function(){                
                	var element = $(this);
                	var del_username = element.attr("id");
                	var info = 'user4passchange=' + del_username;
                	var con;
                	//if(con=confirm("Apakah anda yakin akan mereset password "+del_username+" menjadi \'abc\' ?"))
                	{
                  		//if(con==true){                    
                 			$.ajax({
                   			type: "POST",
                   			//url:siteUrl+'/user/doresetpassword',
                   			url:siteUrl+'/user/set_usr4psschange',
                   			data: info,
                   			success: function(){ 
                   				//alert("Reset password telah berhasil");
                   				window.location.href=siteUrl+'/user/gantipassword';
                   			}
                        });
                     	$(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "slow")
                  			.animate({ opacity: "hide" }, "slow");
                 		/*}else
                 		{
                     		window.location.href=siteUrl+'/user/index';
                 		}*/
                 	}
                	return false;
                });
            });
        </script>

		<script type="text/javascript">
        	$(function() {
            	$(".hapususer").click(function(){ 
                	var element = $(this);
                	var del_id = element.attr("id");
                	var info = 'id=' + del_id;
                	var con;
                	if(con=confirm("Apakah anda ingin menghapus data user ini?"))
                	{
                  		if(con==true){
                 			$.ajax({
                   				type: "POST",
                   				url:siteUrl+'/home/hapususer',
                   				data: info,
                   				success: function(){        
	                   				location.reload();
                   				}
                        	});
                    		$(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "slow")
                  			.animate({ opacity: "hide" }, "slow");
                 		}
                 		else
                 		{
                    		window.location.href=siteUrl+'/user';
                 		}
                 	}
                	return false;
                });
       		});
        </script>

		<script type="text/javascript">
			jQuery(function($) {
				var oTable1 = $('#sample-table-2').dataTable( {
				"aoColumns": [
			      { "bSortable": false },{ "bSortable": false },
			      null,null,null,null,null,
				] } );
				
				
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
				});
			
			
				$('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
				function tooltip_placement(context, source) {
					var $source = $(source);
					var $parent = $source.closest('table')
					var off1 = $parent.offset();
					var w1 = $parent.width();
			
					var off2 = $source.offset();
					var w2 = $source.width();
			
					if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
					return 'left';
				}
			})
		</script>
        </body>
</html>
